//LiuZh 2017-05-17
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
    View,
    StyleSheet,
    Text,
    Image,
    TouchableOpacity,
    Dimensions,
    Modal,
    TouchableHighlight
} from 'react-native';
import Util from '../utils/util.js';

export default class ImageComponent extends Component {

    static propTypes = {
        source: PropTypes.string,
        width: PropTypes.number,
        height: PropTypes.number,
        onPress: PropTypes.func,
    }

    static defaultProps = {

    }

    constructor(props) {
        super(props)
        this.state = {
        }
    }

    render() {
        /*let source;
        if (this.props.source.substring(0, 7) === '/media/') {
            source = { uri: Constant.serverUrl + this.props.source };
        } else {
            let localSource = this.props.source;
            if (localSource.indexOf("@") != -1) {
                localSource = Util.substrImageUrl(this.props.source);
            }
            source = require(localSource);
            
        }
        */
        const instance = this;
        return (
            <TouchableHighlight style={this.props.style}
                onPress={() => this.props.onPress(this.props.source)}>
                <Image source={{uri:this.props.source}} 
                 style={{ width: this.props.width, height: this.props.height }}
                resizeMode={"stretch"}
                />
            </TouchableHighlight>
        )
    }
}

const styles = StyleSheet.create({


});